package com.example.hzit.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket apiDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .paths(PathSelectors.ant("/api/**"))
                .build();
    }

    @Bean
    public Docket adminDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(adminInfo())
                .select()
                .paths(PathSelectors.ant("/admin/**"))
                .build();
    }

        return new ApiInfoBuilder()
                .version("1.0.0")
                .title("API文档")
                .description("本文档描述了API接口")
                .contact(new Contact("普通用户", "http://hzitxx.com", "23232441@qq.com"))
                .build();
    }

    private ApiInfo adminInfo() {
        return new ApiInfoBuilder()
                .version("1.0.0")
                .title("后台管理员API文档")
                .description("本文档描述了后台管理员系统接口")
                .contact(new Contact("管理员", "http://hzitxx.com", "23232448@qq.com"))
                .build();
    }
}
